package com.songcha.sakura.gson

import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import java.lang.reflect.Type

class GsonMapAdapter : JsonDeserializer<MutableMap<String,Any>> {
    override fun deserialize(
        json: JsonElement?,
        typeOfT: Type?,
        context: JsonDeserializationContext?
    ): MutableMap<String, Any> {
         json?.let {
            val resultMap :MutableMap<String,Any> = mutableMapOf ()
            val jsonObject=it.asJsonObject
            val entrySet=jsonObject.entrySet()
            for (entry in entrySet){
                resultMap[entry.key] = entry.value
            }
            return resultMap
        }
        return mutableMapOf()
    }

}